package src.main.kotlin.day09

/**
 * 数据类
 *  copy
 *
 */

fun main() {
    val dataCopyClass = DataCopyClass("jack")
    val copy = dataCopyClass.copy("rose")
    println(dataCopyClass)
    println(copy)





}
   
//data 关键字修饰 数据类
data class DataCopyClass(val name:String,val age:Int){

    private val hobby = "music"
    val subject:String
    //注意的点
    var score = 0

    init {
        println("init class")
        subject = "math"
    }

    constructor(_name:String) : this(_name,10){
        //次构造函数中的赋值，copy不会复制过去，需要在使用的copy之后自行赋值
        score = 10
    }

    override fun toString(): String {
        return "DataCopyClass(name='$name', age=$age, hobby='$hobby', subject='$subject', score=$score)"
    }


}